package edu.ynu.se.xiecheng.achitectureclass.device.service;

import edu.ynu.se.xiecheng.achitectureclass.common.service.LogicService;
import edu.ynu.se.xiecheng.achitectureclass.device.dao.DeviceDAO;
import edu.ynu.se.xiecheng.achitectureclass.device.entity.Device;
import edu.ynu.se.xiecheng.achitectureclass.greenhouse.dao.GreenhouseDAO;
import edu.ynu.se.xiecheng.achitectureclass.greenhouse.entity.Greenhouse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityNotFoundException;
import java.util.List;

@Service
public class DeviceService extends LogicService<DeviceDAO, Device, Long> {

    @Autowired
    public DeviceService(DeviceDAO dao) {
        super(dao);
    }

    public List<Device> getSoilDevices(String greenhouseNumber) {
        return dao.findByGreenhouse_GreenhouseNumber(greenhouseNumber);
    }

    public Device getDeviceByNumber(String deviceNumber) {
        return dao.findByDeviceNumber(deviceNumber);
    }

    public List<Device> getDevicesByCategory(String category) {
        return dao.findByCategory(category);
    }
}
